package cn.edu.gdpt.mobile0123456789hwh0409;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
//1、控件初始化:声明全局控件变量、定义和调用initView()方法
public class MainActivity extends AppCompatActivity {
    private RecyclerView rvMainPart;
    private int[] partIDs={R.drawable.ui_body01,R.drawable.ui_dipan01,
            R.drawable.ui_door01,R.drawable.ui_fadongji01,R.drawable.ui_fangxiangpan01,
            R.drawable.ui_houboli01,R.drawable.ui_luntai01,R.drawable.ui_qianboli01,
            R.drawable.ui_qiangai01,R.drawable.ui_xuangua01,R.drawable.ui_zhuoyi01};
    private String[] partNames={"车身","底盘","车门","发动机","方向盘"
            ,"后玻璃","轮胎","前玻璃","前盖","悬挂","座椅"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
//        设置控件的布局方式为线性方式
        rvMainPart.setLayoutManager(new LinearLayoutManager(this));
//        定义适配性对象
        PartRVAdapter adapter=new PartRVAdapter(partIDs,partNames);
//        给列表控件设置适配器
        rvMainPart.setAdapter(adapter);
    }
    private void initView() {
        rvMainPart = (RecyclerView) findViewById(R.id.rvMainPart);
    }
}